//
//  NewUnitController.m
//  MapEdit
//
//  Created by Steven Canfield on 6/29/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "NewUnitController.h"


@implementation NewUnitController
- (void)awakeFromNib {
	int ownerIndex = 0;
	while( ownerIndex < 12 ) {
		NSMenuItem * item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%i", ownerIndex] action:@selector(newUnitInfoChanged:) keyEquivalent:@""];
		[item setEnabled:YES];
		[item setTarget:self];
		[[ownerPopup menu] addItem: item ];
		ownerIndex++;
	}

	int typeIndex = 0;
	while( typeIndex < 228 ) {
		NSMenuItem * item = [[NSMenuItem alloc] initWithTitle:[[Unit unitNames] objectAtIndex:typeIndex] action:@selector(newUnitInfoChanged:) keyEquivalent:@""];
		[item setEnabled:YES];
		[item setTarget:self];
		[[typePopup menu] addItem: item ];
		typeIndex++;
	}
}

- (IBAction)newUnitInfoChanged:(id)sender {
//	NSMenuItem * from = (NSMenuItem *)sender;
	/*if( [[ownerPopup itemArray] containsObject: from] ) {
		
	} else if( [[typePopup itemArray] containsObject: from] ) {
		
	}*/
}

- (NSInteger)newUnitOwner {
	return [ownerPopup indexOfSelectedItem];
}

- (NSInteger)newUnitType {
	return [typePopup indexOfSelectedItem];
}
@end
